package br.com.threads;
class FDG implements Runnable{
	private Integer valor = 100;
	private Integer retirado = 30;
	public void run(){
		try{
			for(int i= 0; i < 2; i++){
				System.out.println(Thread.currentThread().getName());
				retirar();
				Thread.sleep(300);
			}
		}catch(InterruptedException e){}
	}
	public void retirar(){
		
		if(retirado <= valor){
			System.out.println("Valor Retirado: " + retirado);
			valor -= retirado;
			System.out.println("Valor Restante: " + valor);
		}else{
			System.out.println("Nao Pode Retirar!");
		}		
	}
	public void setRetirado(int retirado){
		this.retirado = retirado;
	}
	public Integer getRetirado(){
		return retirado;
	}
}
public class Programa40 {
	public static void main(String[] args) {
		FDG f = new FDG();
		Thread [] t = new Thread[15];
		for(int i = 0; i < t.length; i++){
			t[i] = new Thread(f);
			t[i].setName("Sacador -> " + i);
			t[i].start();
		}		
	}
}
